
//
//  OpinionViewController.m
//  HandWork
//
//  Created by 王阳阳 on 16/1/22.
//  Copyright © 2016年 www.lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "OpinionViewController.h"

@interface OpinionViewController ()<UITextViewDelegate>

@property (nonatomic, retain)UITextView *textView;//textView需要书写的地方
@property (nonatomic, retain)UILabel *labelp;//点击清除的label
@end

@implementation OpinionViewController
-(void)dealloc
{
    [_textView release];
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    

    //标题 用户反馈
    UILabel *title = [[UILabel alloc]initWithFrame:CGRectMake(150, 20, 80, 30)];
    title.text = @"用户反馈";
    [self.view addSubview:title];//添加
    
    
    
    //创建textView
    self.textView = [[UITextView alloc]initWithFrame:CGRectMake(0, 50,self.view.frame.size.width, 270)];
    self.textView.delegate= self;//代理
    self.textView.backgroundColor = [UIColor grayColor];//背景颜色textView的
    //键盘
    self.textView.keyboardType = UIKeyboardAppearanceDefault;
    self.textView.font = [UIFont systemFontOfSize:17];//字体大小
    [self.view addSubview:self.textView];//添加
    [_textView release];
    
    //创建label
    self.labelp = [[UILabel alloc]initWithFrame:CGRectMake(5, 5, CGRectGetWidth(self.textView.frame), 30)];
//    _labelp.textColor= [UIColor grayColor];
    _labelp.text = @"请输入您的宝贵意见😃";
    _labelp.font = self.textView.font;//label的字体大小和textView书写的字体一样大
    [self.textView addSubview:_labelp];
    [_labelp release];
    
    //创建button
    UIButton *but = [UIButton buttonWithType:UIButtonTypeSystem];
    //button 的大小和位置
    but.frame = CGRectMake(5, 400, self.view.frame.size.width - 10, 30);
    //button 的名字
    [but setTitle:@"提交" forState:UIControlStateNormal];
    but.layer.borderWidth = 1;//button 的边框粗细
    [but addTarget:self action:@selector(go) forControlEvents:UIControlEventTouchUpInside];//button的点击
    [self.view addSubview:but];
}
#pragma mark - button的点击方法 点击返回首页
- (void)go
{
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}
#pragma mark - 已经开始书写的时候label清零
- (void)textViewDidBeginEditing:(UITextView *)textView
{
    _labelp.text = @"";
    _textView.keyboardType = UIKeyboardAppearanceAlert;
    
    
}
#pragma mark - 已将结束书写的时候
- (void)textViewDidEndEditing:(UITextView *)textView
{
    
    //textView 的长度为0的情况下 显示label
    if (self.textView.text.length == 0) {
        _labelp.text = @"请输入您的宝贵意见😃";
    }
    else
    {
        _labelp.text = @"";
    }
}
#pragma mark - 点击屏幕让键盘收起 

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [self.view endEditing:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
